<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title th:text="#{i18n.text_2}"></title>
	<head th:replace="head"/>
	<style>
		.dashbord_content_outer{
			background-color: #fff;
		}
		.minertable-top{
			margin-top: 20px;
		}
		.modal-dialog {
		    width: 800px;
		    margin: 30px auto;
		}

	</style>

	<link rel="stylesheet" th:href="@{/css/bootstrap-switch.min.css}"/>

</head>
<body>
<nav th:replace="nav"/>
<section class="layout">
	<div class="horizontal-content">
		<div class="middle">
			<div class="md_content">
				<div class="md_content">
					<div class="apicontent">
						<!-- <div class="APItitle">
							系统设置
						</div>
						<div class="api_md">
							<table >
								<tr>
									<td colspan="3">当前币种 &nbsp;
										<span class="set_email">BTC</span>
									</td>
								</tr>
								<tr>
									<td width="22%">注册邮箱 &nbsp;<span id="email" class="set_email" th:text="${email}"></span></td>
									<td width="49%">时区 &nbsp;
										<span id="timezone_control_span">
								  (GMT) 欧洲西部时间, 伦敦, 里斯本, 卡萨布兰卡
                           		</span>
										<select id="timezone_control" name="timezone_control" disabled="disabled" style="display: none;">
											<option value="-720" >(GMT -12:00) 埃尼威托克岛, 夸贾林环礁</option>
											<option value="-660" >(GMT -11:00) 萨摩亚, 中途岛</option>
											<option value="-600" >(GMT -10:00) 夏威夷</option>
											<option value="-540" >(GMT -9:00) 阿拉斯加</option>
											<option value="-480" >(GMT -8:00) 太平洋时间 (美国 &amp; 加拿大)</option>
											<option value="-420" >(GMT -7:00) 山区标准时间 (美国 &amp; 加拿大)</option>
											<option value="-360" >(GMT -6:00) 中部时间 (美国 &amp; 加拿大), 墨西哥城</option>
											<option value="-300" >(GMT -5:00) 东部时间 (美国 &amp; 加拿大), 波哥大, 利马</option>
											<option value="-240" >(GMT -4:00) 大西洋时间 (加拿大), 加拉加斯, 拉巴斯</option>
											<option value="-210" >(GMT -3:30) 纽芬兰岛</option>
											<option value="-180" >(GMT -3:00) 巴西, 布宜诺斯艾利斯, 乔治敦</option>
											<option value="-120" >(GMT -2:00) 中大西洋</option>
											<option value="-60" >(GMT -1:00 小时) 亚速尔群岛, 佛得角群岛</option>
											<option value="0" selected="selected">(GMT) 欧洲西部时间, 伦敦, 里斯本, 卡萨布兰卡</option>
											<option value="60" >(GMT +1:00 小时) 布鲁塞尔, 哥本哈根, 马德里, 巴黎</option>
											<option value="120" >(GMT +2:00) 加里宁格勒, 南非</option>
											<option value="180" >(GMT +3:00) 巴格达, 利雅得, 莫斯科, 圣彼得堡</option>
											<option value="210" >(GMT +3:30) 德黑兰</option>
											<option value="240" >(GMT +4:00) 阿布扎比, 马斯喀特, 巴库, 巴库</option>
											<option value="270" >(GMT +4:30) 喀布尔</option>
											<option value="300" >(GMT +5:00) 叶卡捷琳堡, 伊斯兰堡, 卡拉奇, 塔什干</option>
											<option value="330" >(GMT +5:30) 孟买, 加尔各答, 马德拉斯, 新德里</option>
											<option value="360" >(GMT +6:00) 阿拉木图, 达卡, 科伦坡</option>
											<option value="390" >(GMT +6:30) 缅甸</option>
											<option value="420" >(GMT +7:00) 曼谷, 河内, 雅加达</option>
											<option value="480" >(GMT +8:00) 北京,珀斯,新加坡,香港</option>
											<option value="540" >(GMT +9:00) 东京,汉城,大阪,札幌,雅库茨克</option>
											<option value="570" >(GMT +9:30) 阿德莱德,达尔文</option>
											<option value="600" >(GMT +10:00) 海参崴东部,关岛,澳大利亚</option>
											<option value="660" >(GMT +11:00) 马加丹,所罗门群岛,新喀里多尼亚</option>
											<option value="720" >(GMT +12:00) 奥克兰,惠灵顿,斐济群岛,堪察加半岛</option>
										</select>
									</td>
									<td valign="top" style="width:25%; padding-right:22px;">
										<input id="timezone_hidden" type="hidden" value="0"/>
										<button id="timezone_btn_edit" class="btn24"  style="float:right;margin-right:7px;" onclick="f_timezone_edit();" >编辑</button>
										<button id="timezone_btn_cancel" class="btn24"  style="float:right;margin-right:7px;display: none" onclick="f_timezone_cancel();" >取消</button>
										<button id="timezone_btn_save" class="btn24"  style="float:right;margin-right:7px;display: none" onclick="f_timezone_save();" >保存</button>
									</td>
								</tr>

							</table>
						</div> -->
						<div style=" margin-top:30px;">
							<div style=" float:left; " class="APItitle" th:text="#{i18n.text_101}"></div>
							<div style=" float:right;">
								<input type="button" class="btn24" data-toggle="modal"  data-target="#dialog_add_userid" style="float:left; margin-right:28px;" th:value="#{i18n.text_102}"/>
							</div>
						</div>
						<div style=" padding-top:20px;clear:both;">
							<table class="table table-bordered table-striped ">
								<tr>
									<th width="10%" th:text="#{i18n.text_85}"></th>
									<th width="8%" th:text="#{i18n.text_103}"></th>
									<th width="8%" th:text="#{i18n.text_104}"></th>
									<th width="9%" th:text="#{i18n.text_105}"></th>
									<th width="35%" th:text="#{i18n.text_99}"></th>
								</tr>
								<tr th:each="bmpAccount : ${bmpAccounts}">
									<td style="height: 50px;" th:text="${bmpAccount.name}">
										
									</td>
									<td>
										<div th:text="${bmpAccount.coinType}">
										</div>
									</td>
									<td>
										<div style="padding: 5px 0 0 5px;" th:text="${bmpAccount.payMode}"></div>
									</td>
									<td>
										<div style="padding: 5px 0 0 5px;" th:text="${bmpAccount.remark}"></div>
									</td>
									<td th:attr="account_id=${bmpAccount.id}">
										<input data-toggle="modal" data-target="#wallet_edit_coin" type="button" class="btn24 wallet_edit_coin"  th:value="#{i18n.text_191}" />
										<input data-toggle="modal" type="button" data-target="#wallet_look_address" class="btn24 wallet_address_info"  th:value="#{i18n.text_192}" style="margin:0 8px;"/>
										<input type="button" class="btn24b wallet_address_del"  th:value="#{i18n.text_108}" />
									</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<footer th:replace="footer"/>
</section>
<!--模态窗口 添加用户ID-->
<div class="modal fade" id="dialog_add_userid" tabindex="-1" role="dialog">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close"
				        data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel" th:text="#{i18n.text_102}">
				</h4>
			</div>
			<div class="modal-body">
				<table style=" margin-top:10px;">
					<tr>
						<td>
							<input id="newuseridIn" type="text" th:placeholder="#{i18n.text_110}" />
							<button class="bigbutton" style=" margin-left:20px; " name="addBtn" th:text="#{i18n.text_111}"></button>
						</td>
					</tr>
					<tr>
						<td>
							<span id="dialog_add_userid_msg" style="color: red;"></span>
						</td>
					</tr>
					<tr>
						<td>
							<span style=" font-size:12px; color:#aaaaaa;" th:text="#{i18n.text_112}"></span>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>

<!--模态窗口 切换挖币币种-->
<div class="modal fade" id="wallet_edit_coin" tabindex="-1" role="dialog">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close"
				        data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">
					<span th:inline="text">[[#{i18n.text_85}]]：</span><span class="accountName_edit_coin" value="">XXXXX</span>
				</h4>
			</div>
			<div class="modal-body">
				<table style=" margin-top:10px;">
					<tr>
						<td th:text="#{i18n.text_103}"></td>
						<td>
							<select class="xSelect" name="timezone_control" style="">
							
							</select>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="text-align: center;padding-top: 30px;">
							<button class="bigbutton fNone btn_wallet_edit_coin" style="width:160px;" name="" th:text="#{i18n.text_86}"></button>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>

<!--模态窗口 添加钱包地址-->
<div class="modal fade" id="wallet_add_address" tabindex="-1" role="dialog">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close"
				        data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">
					<span th:inline="text">[[#{i18n.text_85}]]：</span><span class="accountName_Add" value="">XXXXX</span>
				</h4>
			</div>
			<div class="modal-body">
				<table style=" margin-top:10px;">
					<tr>
						<input type="hidden" id="walletId"/>
						<td th:text="#{i18n.text_103}"></td>
						<td>
							<select id="coinType" class="xSelect" name="timezone_control" style="">
								<option th:each="coinType : ${coinTypes}" th:value="${coinType.value}" th:selected="${#strings.contains(coinType.value,'BTC')}" th:text="${coinType.text}"></option>
 							</select>
						</td>
					</tr>
					<tr>
						<td th:text="#{i18n.text_104}"></td>
						<td>
							<select id="payMode" class="xSelect" name="timezone_control" style="">
								<option th:each="payMode : ${payModes}" th:value="${payMode.value}" th:selected="${#strings.contains(payMode.value,'FPPS')}"  th:text="${payMode.text}"></option>
							</select>
						</td>
					</tr>
					<tr>
						<td th:text="#{i18n.text_115}"></td>
						<td>
							<input id="walletAddr" type="text" value="" style="width:420px;border-color: rgb(169, 169, 169);"/>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<span style=" font-size:12px; color:#aaaaaa;" th:text="#{i18n.text_117}"></span>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<span class="btn_wallet_add_address_error" style="color: red;"></span>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="text-align: center;">
							<button class="bigbutton fNone btn_wallet_add_address" style="width:160px;" name="" th:text="#{i18n.text_118}"></button>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<!--模态窗口 查看钱包地址-->
<div class="modal fade" id="wallet_look_address" tabindex="-1" role="dialog">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close wallet_look_address"
				        data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">
					<span th:inline="text">[[#{i18n.text_85}]]：</span><span class="accountName_info" account_id="">XXXXX</span>
				</h4>
			</div>
			<div class="modal-body">
				<table class="table" style="margin-top:10px;">
					<tr>
						<th th:text="#{i18n.text_103}"></th>
						<th th:text="#{i18n.text_104}"></th>
						<th th:text="#{i18n.text_115}"></th>
						<th th:text="#{i18n.text_193}"></th>
					</tr>
					<tr>
						<td colspan="4" style="text-align: center;padding:20px 0 0 0;">
							<input data-toggle="modal" data-target="#wallet_add_address" type="button" class="bigbutton btn24 wallet_add_address"  th:value="#{i18n.text_106}" />
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<script th:inline="javascript">
/*<![CDATA[*/
	$(function() {

		$('#dialog_add_userid button[name=addBtn]').bind('click',function(e) {
			$("#dialog_add_userid_msg").text("");
			var newuseridIn = $('#newuseridIn').val();
			$.ajax({
				type : "POST",
				url : "/user/addAccount",
				data : {name:newuseridIn},
				dataType:"json",
				success : function(data) {
					if(data.code=='200') {
						window.location.href = "/home/setting";
					} else {
						$("#dialog_add_userid_msg").text(data.msg);
					}
				}
			});
		});
		
		//切换币种
		$(".wallet_edit_coin").click(function(){
			var accountName = $(this).parents("tr").find("td:first-child").text();
			$(".accountName_edit_coin").text(accountName);
			var account_id = $(this).parents("td").attr("account_id");
			$(".accountName_edit_coin").val(account_id);
			var coinType = $(this).parents("tr").find("td:nth-child(2)").text().trim();
			//查询钱包地址
			$.post("/user/walletAddrs",{accountId:account_id},function(data){
				if(data.code=='200'){
					var html = "";
					$("#wallet_edit_coin select").empty(); 
					$.each(data.data,function(i,e){
						if(coinType == e.coinType){
							html +="<option value='"+e.id+"' selected='selected'>"+e.coinType+"</td>";
						}else{
							html +="<option value='"+e.id+"'>"+e.coinType+"</td>";
						}
					});		
					$("#wallet_edit_coin select").append(html);
				}
			},'json');
		});
		
		//切换币种
		$("#wallet_edit_coin .btn_wallet_edit_coin").click(function(){
			var walletId = $("#wallet_edit_coin select").val();
			var accountId = $(".accountName_edit_coin").val();
			$.post("/user/editCoin",{walletId:walletId,accountId:accountId},function(data){
				if(data.code=='200') {
					window.location.href = "/home/setting";
				} else {
					alert(data.msg);
				}
			},'json');
		});
		
		//添加钱包地址
		$(".wallet_add_address").click(function(){
			$(".close.wallet_look_address").trigger("click");
			$(".accountName_Add").text($("#wallet_look_address .accountName_info").text())
			var account_id = $(".accountName_info").attr("account_id");
			$(".accountName_Add").val(account_id);
			$(".btn_wallet_add_address").text([[#{i18n.text_118}]]);
			$(".btn_wallet_add_address_error").text("");
			$("#walletId").val("");
		});
		
		//修改钱包地址
		$("#wallet_look_address").on("click",".wallet_edit_address",function(){
			$(".close.wallet_look_address").trigger("click");
			var accountInfo = $("#wallet_look_address .accountName_info");
			$(".accountName_Add").text(accountInfo.text())
			var account_id = accountInfo.attr("account_id");
			$(".accountName_Add").val(account_id);
			$(".btn_wallet_add_address").text([[#{i18n.text_194}]]);
			$(".btn_wallet_add_address_error").text("");
			
			var tr =  $(this).parents("tr");
			var tds = tr.find("td");
			var coinType = tds[0].innerText;
			var payMode = tds[1].innerText;
			var walletAddr = tds[2].innerText;
			$("#walletAddr").val(walletAddr);
			$("#coinType").val(coinType);
			$("#payMode").val(payMode);
			$("#walletId").val(tr.attr("walletId"));
		});
		
		function queryWalletAddrs(account_id){
			$.post("/user/walletAddrs",{accountId:account_id},function(data){
				if(data.code=='200'){
					$(".walletAddrs_tr").remove();
					var html = "";
					var delText = [[#{i18n.text_196}]];
					var modifyText = [[#{i18n.text_194}]];
					$.each(data.data,function(i,e){
						html += "<tr class=\"walletAddrs_tr\" walletId ="+e.id+">";
						html +="<td style=\"text-align: center;\">"+e.coinType+"</td>";
						html +="<td style=\"text-align: center;\">"+e.payMode+"</td>";
						html +="<td style=\"text-align: center;\">"+e.walletAddr+"</td>";
						html +="<td style=\"text-align: center;\">"+
							"<input type=\"button\" class=\"btn24 wallet_edit_address\" data-toggle=\"modal\" data-target=\"#wallet_add_address\" value=\""+modifyText+"\"/>&nbsp;"+
							"<input type=\"button\" class=\"btn24 wallet_del_address\" value=\""+delText+"\"/></td>";
						html +="</tr>";
					});		
					$("#wallet_look_address table tbody tr:first-child").after(html);
				}
			},'json');
		}
		
		//删除钱包地址
		$("#wallet_look_address").on("click",".wallet_del_address",function(){
			var tr =  $(this).parents("tr");
			var walletId = tr.attr("walletId");
			if(confirm([[#{i18n.text_195}]])){
				$.ajax({
					type : "POST",
					url : "/user/delWalletAddr",
					data : {walletId:walletId},
					dataType:'json',
					success : function(data) {
						if(data.code=='200') {
							var account_id =$("#wallet_look_address .accountName_info").attr("account_id");							
							queryWalletAddrs(account_id);
						} else {
							alert(data.msg);
						}
					}
				});
			}
		});
		
		
		//查询
		$(".wallet_address_info").click(function(){
			var accountName = $(this).parents("tr").find("td:first-child").text();
			$("#wallet_look_address .accountName_info").text(accountName);
			var account_id = $(this).parents("td").attr("account_id");
			$("#wallet_look_address .accountName_info").attr("account_id",account_id);
			queryWalletAddrs(account_id);
			
		});
		//添加
		$(".btn_wallet_add_address").click(function(){
			$(".btn_wallet_add_address_error").text("");
			var coinType = $("#coinType").val();
			var payMode = $("#payMode").val();
			var walletAddr = $("#walletAddr").val();
			var walletId = $("#walletId").val();
			if(""==walletAddr){
				return false;
			}
			
			var accountId = $(".accountName_Add").val();
			$.post("/user/addwalletAddr",{
				accountId:accountId,
				coinType:coinType,
				payMode:payMode,
				walletAddr:walletAddr,
				id:walletId
			},function(data){
				if(data.code=='200'){
					alert([[#{i18n.text_198}]]+data.data+","+[[#{i18n.text_199}]]);
					window.location.href = "/home/setting";
				}else{
					$(".btn_wallet_add_address_error").text(data.msg);
				}
			},"json")
		});
		
		$(".wallet_address_del").click(function(){
			if(confirm([[#{i18n.text_197}]])){
				var account_id = $(this).parents("td").attr("account_id");
				$.ajax({
					type : "POST",
					url : "/user/delAccount",
					data : {accountId:account_id},
					dataType:'json',
					success : function(data) {
						if(data.code=='200') {
							window.location.href = "/home/setting";
						} else {
							alert(data.msg);
						}
					}
				});
			}
		});

	});
/*]]>*/
</script>
<script th:inline="javascript">
	var accountId = [[${accountId}]];
	if(accountId==null){
		$('#useridSetModal').modal();
		$('#userIdSave').bind('click', function(e) {
			var userIdIn=$('#userIdIn').val();
			$.ajax({
				type : "POST",
				url : "/user/addAccount",
				data : {name:userIdIn},
				success : function(data) {
					if(data.code=='200') {
						$('#useridSetModal').modal('hide');
						window.location.reload(true);
					} else {
						$('#dialog_msg').html(data.msg);
					}
				}
			});
		});
		document.onkeydown = function (event){
		　　if (event.keyCode==13){
			//回车键的键值为13
			$("#userIdSave").trigger("click");
		　　} 
	　　	};
	}
</script>
</body>
</html>